#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
struct js{char x;int id;};
int n,k,sum;
stack<js> st;
char ch[1010],f[1010];
int b[1010],s=0,ij;
inline bool checkc(char c){
	if(c=='('||c==')'||c=='*'||c=='?') return true;
	else return false;
}
void read(int &x){
	x=0;int f=1;char c=0;
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	x=x*f;
}
bool chezh(int l,int r)
{
	for(int i=l;i<=r;i++){
		if(f[i]=='(') return false;
	}
	return true;
}
bool check()
{
	while(!st.empty()) st.pop();
	if(f[1]!='('||f[ij]!=')') return false;
	int tot=0;
	for(int i=1;i<=ij;i++){
		if(f[i]=='(') st.push((js){f[i],i}),tot=0;
		else if(f[i]=='*'){
			tot++;
			if(tot>k) return false;
			st.push((js){f[i],i});
		}else{
			if(st.empty()) return false;
			while(st.top().x!='('){
				st.pop();
				if(st.empty()) return false;
			}
			if(f[st.top().id+1]=='*'&&f[i-1]=='*'&&!chezh(st.top().id+1,i-1)) return false;
			st.pop();
			tot=0;
		}
	}
	while(!st.empty()){
		if(st.top().x!='*') return false;
		st.pop();
	}
	return true;
}
void dfs(int x)
{
	if(x>sum){
		int ix=1;
		for(int i=1;i<=ij;i++){
			if(ch[i]!='?') f[i]=ch[i];
			else{
				if(b[ix]==1) f[i]='(';
				else if(b[ix]==2) f[i]=')';
				else f[i]='*';
				ix++;
			}
		}
		if(check()) s++;
	}else{
		for(int i=1;i<=3;i++){
			b[x]=i;
			dfs(x+1);
			b[x]=0;
		}
	}
}
int main()
{
	int i,j;char c=0;
	freopen("bracket.in","r",stdin);
	freopen("bracket.out","w",stdout);
	read(n);read(k);
	while(!checkc(c)) c=getchar();
	while(checkc(c)){
		ch[++ij]=c;
		if(c=='?') sum++;
		c=getchar();
	}
	dfs(1);
	cout<<s<<endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
}
